﻿@{
    ViewData["Title"] = "AddRole";
    Layout = null;
}

<link rel="stylesheet" href="~/layui/css/layui.css">

@*引用*@
<script src="~/Scripts/jquery-3.4.1.min.js"></script>
<script src="~/layer/Model/appsettings.js"></script>
<script src="~/layui/layui.js"></script>

<div style="width:800px">
    <form class="layui-form" action="/Setup/updaterole">
        <div class="layui-form-item">
            <div class="layui-input-block">
                <input id="Id" name="Id" type="hidden" value="@ViewBag.id" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">角色名称：</label>
            <div class="layui-input-block">
                <input type="text" id="Name" name="Name" required lay-verify="required" placeholder="请输入角色名称" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">上级名称：</label>
            <div class="layui-input-block">
                <input type="text" id="Pid" name="Pid" required lay-verify="required" placeholder="请输入上级名称" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">别名：</label>
            <div class="layui-input-block">
                <input type="text" id="RoleAlias" name="RoleAlias" required lay-verify="required" placeholder="请输入别名" autocomplete="off" class="layui-input">
            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" type="submit" lay-submit>立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary" onclick="tz()">返回</button>
            </div>
        </div>
    </form>
</div>

<script>
        //Demo
    layui.use('form', function(){
      var form = layui.form;
      form.render();
      //监听提交

      form.on('submit(formDemo)', function(data){
      });
    });

    var tz=function(){
        location.href="/Setup/Index"
    }

        $(function () {
            $.ajax({
                url: "/Setup/GetBack?id=" + @ViewBag.id,
                type: "get",
                dataType: "json",
                success: function (obj) {
                    $("#Name").val(obj.name)
                    $("#Pid").val(obj.pid)
                    $("#RoleAlias").val(obj.roleAlias)
                }
            })
        })
</script>
